// 文章

// 1.导入 express
const express = require("express");

const multer = require("multer");

// 导入内置模块
const path = require("path");

const expressJoi = require("@escook/express-joi");
// 导入验证的规则
const { add_article_schema } = require("../schema/article");

// 指定上传图片的文件夹
const uploads = multer({ dest: path.join(__dirname, "../uploads") });

// 2. 创建路由对象
const router = express.Router();

const articleHandler = require("../router_handler/article");

// 创建添加文章的路由

router.post("/add", uploads.single("cover_img"), expressJoi(add_article_schema), articleHandler.addArticle);

// 3. 将路由对象暴露出去

module.exports = router;
